import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

import {LOCAL_SPORT_TYPE_IMG_PATH} from "../../providers/Constants";
// import {CityPickerService} from "../../providers/CityPickerService";
import {Login} from "../login/login";
import {SportDetailPage} from "../sport-detail/sport-detail";
import {CheckUtil} from "../../common/CheckUtil";

@IonicPage()
@Component({
  selector: 'page-my-sports',
  templateUrl: 'my-sports.html',
})
export class MySportsPage {
  title:string;
  sportList:any;
  localSportTypeImgPath:string;

  cityData: any[]; //城市数据
  cityName:string = '北京市 北京市'; //初始化城市名
  code:string; //城市编码
  constructor(public navCtrl: NavController,
              public navParams: NavParams,
              // public cityPickerSev: CityPickerService,
              public checkUtil:CheckUtil) {
    this.title =this.navParams.get("title");
    this.sportList = this.navParams.get('sportList');
    this.localSportTypeImgPath = LOCAL_SPORT_TYPE_IMG_PATH;
    console.log(this.sportList);
    // this.setCityPickerData();
  }

  ionViewDidLoad() {

  }


  /**
   * 获取城市数据
   */
  // setCityPickerData(){
  //   this.cityPickerSev.getCitiesData().subscribe(res=>{
  //     this.cityData = res;
  //   })
  // }

  /**
   * 城市选择器被改变时触发的事件
   * @param event
   */
  // cityChange(event){
  //   console.log(event);
  //   this.code = event['region'].value;
  //   console.log(this.code);
  // }

  //打开运动详情
  goToSportDetail(id){
    if(this.checkUtil.checkUserLogin()){
      this.navCtrl.push(SportDetailPage,{id:id});
    }else {
      this.navCtrl.push(Login,{page:"PublishSport"});//跳转登录
    }
  }

}
